package stud.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import stud.aistar.entity.User;

import java.util.List;

/**
 * @author wangyu
 * @version 1.0
 * @description
 * @createDate 2019/9/27 15:17
 */
public interface UserMapper {

    @Select("select * from user")
    List<User> findAll();
    @Select("select * from user where username=#{value}")
    User findByUsername(String username);

    @Select("select * from user where phone=#{value}")
    User findByPhone(String phone);

    @Insert("Insert into user(username,password,phone,create_time,phone_id) values(#{u.username},#{u.password},#{u.phone},#{u.createTime},#{u.phoneId})")
    void save(@Param("u") User user);

    @Update("update user set password = #{u.password} where phone_id = #{pid}")
    void updPwd(@Param("pid") Integer phoneId,@Param("u") User user);
}
